Taming Control Flow: A Structured Approach to Eliminating Goto Statements
نویسندگان
چکیده
1994 IEEE. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works must be obtained from the IEEE. Abstract In designing optimizing and parallelizing compilers, it is often simpler and more eecient to deal with programs that have structured control ow. Although most programmers naturally program in a structured fashion, there remain many important programs and benchmarks that include some number of goto statements , thus rendering the entire program unstruc-tured. Such unstructured programs cannot be handled with compilers built with analyses and transformations for structured programs. In this paper we present a straightforward algorithm to structure C programs by eliminating all goto statements. The method works directly on a high-level abstract syntax tree (AST) representation of the program and could easily be integrated into any compiler that uses an AST-based intermediate representation. The actual algorithm proceeds by eliminating each goto by rst applying a sequence of goto-movement transformations followed by the appropriate goto-elimination transformation. We have implemented the method in the Mc-CAT (McGill Compiler Architecture Testbed) opti-mizing/parallelizing C compiler and we present experimental results that demonstrate that the method is both eecient and eeective.
منابع مشابه
No More Gotos: Decompilation Using Pattern-Independent Control-Flow Structuring and Semantics-Preserving Transformations
Decompilation is important for many security applications; it facilitates the tedious task of manual malware reverse engineering and enables the use of source-based security tools on binary code. This includes tools to find vulnerabilities, discover bugs, and perform taint tracking. Recovering high-level control constructs is essential for decompilation in order to produce structured code that ...
متن کاملCompiling business processes: untangling unstructured loops in irreducible flow graphs
This paper presents a systematic study of some major problems involved in the transformation of business process modelling languages to executable business process representations. A business process modelling language usually uses the simple concept of ‘goto’ to describe the operation sequence of a business. If a structured language is chosen as the executable representation, it is difficult t...
متن کاملThe Treewidth of Java Programs
Intuitively, the treewidth of a graph G measures how close G is to being a tree. The lower the treewidth, the faster we can solve various optimization problems on G, by dynamic programming along the tree structure. In the paper M.Thorup, All Structured Programs have Small Tree-Width and Good Register Allocation [8] it is shown that the control-flow graph of any goto-free C program is at most 6....
متن کاملDAG-width of Control Flow Graphs with Applications to Model Checking
The treewidth of control flow graphs arising from structured programs is known to be at most six. However, as a control flow graph is inherently directed, it makes sense to consider a measure of width for digraphs instead. We use the so-called DAG-width and show that the DAG-width of control flow graphs arising from structured (goto-free) programs is at most three. Additionally, we also give a ...
متن کاملTheory and algorithms for slicing unstructured programs
Program slicing identifies parts of a program that potentially affect a chosen computation. It has many applications in software engineering, including maintenance, evolution and re-engineering of legacy systems. However, these systems typically contain programs with unstructured control-flow, produced using goto statements; thus, effective slicing of unstructured programs remains an important ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1994